package com.youth.koodoReaderManager.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youth.koodoReaderManager.entity.DictHistory;
import com.youth.koodoReaderManager.mapper.DictHistoryMapper;
import com.youth.koodoReaderManager.service.DictHistoryService;
import org.springframework.stereotype.Service;

@Service
public class DictHistoryServiceImpl extends ServiceImpl<DictHistoryMapper, DictHistory> implements DictHistoryService {

    @Override
    public IPage<DictHistory> pageQuery(IPage<DictHistory> page, DictHistory dictHistory) {
        // 创建查询条件
        QueryWrapper<DictHistory> queryWrapper = new QueryWrapper<>();
        if (dictHistory != null) {
            if (dictHistory.getBookKey() != null && !ObjectUtil.isEmpty(dictHistory.getBookKey())) {
                queryWrapper.eq("book_key", dictHistory.getBookKey());
            }
            if (dictHistory.getWord() != null && !dictHistory.getWord().isEmpty()) {
                queryWrapper.eq("word", dictHistory.getWord());
            }
            // 其他字段的查询条件...
        }
        // 执行分页查询
        return this.page(page, queryWrapper);
    }
}